﻿using Microsoft.EntityFrameworkCore;
using StudentManagerService.Models;

namespace StudentBackendService.Mappers
{
    public class SchoolContext : DbContext
    {
        private readonly IConfiguration _configuration;

        public SchoolContext(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        public DbSet<Student> Students { get; set; }
        public DbSet<StudentSecret> StudentSecrets { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder
            .UseNpgsql(_configuration.GetConnectionString("Postgres"))
            .UseSnakeCaseNamingConvention()
            .LogTo(Console.WriteLine);
    }

}
